package de.bazinga.rotw.zombie;

import java.util.Random;
import java.util.Vector;

import com.jme.math.Vector3f;

public class Waypoint {
	
	private Vector<Waypoint> adjazendWaypoints = null;
	
	private Vector3f location = null;
	
	public Waypoint(Vector3f location) {
		this.location = location;
		this.adjazendWaypoints = new Vector<Waypoint>();
	}
	
	public Waypoint(Vector3f location, Vector<Waypoint> adjazendWaypoints) {
		this.location = location;
		this.setAdjazendWaypoints(adjazendWaypoints);
	}
	
	
	public Waypoint getNextWaypoint() {
		Random r = new Random();
		int waypointIndex = r.nextInt(adjazendWaypoints.size());
		
		return adjazendWaypoints.get(waypointIndex);
	}

	public Vector3f getLocation() {
		return location;
	}

	public void setLocation(Vector3f location) {
		this.location = location;
	}
	
	public void addAdjazentWaypoint(Waypoint w, boolean bothWays) {
		adjazendWaypoints.add(w);
		if(bothWays) w.addAdjazentWaypoint(this,false);
	}

	public void addAdjazentWaypoint(Waypoint w) {
		addAdjazentWaypoint(w, true);
	}
	

	public void setAdjazendWaypoints(Vector<Waypoint> adjazendWaypoints) {
		this.adjazendWaypoints = adjazendWaypoints;
	}

	public Vector<Waypoint> getAdjazendWaypoints() {
		return adjazendWaypoints;
	}
}